home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / ADO Public225377102001.psc / modPhonebook.bas < prev    next >
Encoding:
BASIC Source File  |  2001-07-11  |  1.5 KB  |  47 lines

  1. Attribute VB_Name = "modPhonebook"
  2. 'Module by  Raymond Tan Chiu
  3. 'For your comments and suggestions you can conntact me at:
  4. '           raymondchiu@eudoramail.com
  5. '           rchiu@unionbankph.com
  6. '           raymondchiu@edsamail.com.ph
  7. '           (63)(917)376-1894
  8. '           (63)(032)340-8471
  9. '           (63)(032)254-7500
  10. 'Development Date   : 06-19-2001
  11. 'Description        : Shows a ADO data control binds with datagrid.  And a global connection of ADO
  12. 'Components         : Datagrid, Adodc(ADO Data Control), Datagrid
  13.  
  14. Public gadoConn As ADODB.Connection
  15.  
  16. Sub Main()
  17. 'starting point of all ITC Applications
  18.     On Error Resume Next
  19.     If ConnectToDatabase = False Then
  20.         MsgBox "Database not found!, Please place the database with the same path as the .exe file", vbExclamation, "Database not found!"
  21.     End If
  22.     frmPhonebook.Show
  23. End Sub
  24.  
  25. Public Function ConnectToDatabase() As Boolean
  26. Dim strConnect As String
  27. Dim Path As String
  28.  
  29.     On Error GoTo ConnectError
  30.     Path = App.Path & "\Phonebook.mdb"
  31.     strConnect = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=false;"
  32.     strConnect = strConnect & "Data Source=" & Path & ";Jet OLEDB:Database password = Pure;"
  33.                 
  34.     Set gadoConn = New ADODB.Connection
  35.     gadoConn.CursorLocation = adUseServer
  36.     
  37.     gadoConn.Open strConnect
  38.         
  39.     ConnectToDatabase = True
  40.     
  41.     Exit Function
  42.  
  43. ConnectError:
  44.     MsgBox Error$, vbExclamation, "Connection Error"
  45.     ConnectToDatabase = False
  46. End Function
  47.